<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.bookmanager.model.User" %>
<%
    User user = (User) session.getAttribute("user");
    if (user == null || !"admin".equals(user.getRole())) {
        response.sendRedirect("../login.jsp");
        return;
    }
%>
<html>
<head>
    <title>管理员中心 - 图书管理系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: #f5f7fa;
            color: #333;
        }

        .header {
            background: white;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            padding: 0 20px;
        }

        .nav-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            max-width: 1200px;
            margin: 0 auto;
            height: 70px;
        }

        .logo {
            font-size: 1.5rem;
            font-weight: bold;
            color: #667eea;
        }

        .admin-info {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .admin-badge {
            background: #28a745;
            color: white;
            padding: 4px 8px;
            border-radius: 12px;
            font-size: 0.8rem;
            font-weight: 500;
        }

        .logout-btn {
            padding: 8px 16px;
            background: #dc3545;
            color: white;
            text-decoration: none;
            border-radius: 5px;
            font-size: 0.9rem;
        }

        .container {
            max-width: 1200px;
            margin: 30px auto;
            padding: 0 20px;
        }

        .dashboard-header {
            text-align: center;
            margin-bottom: 40px;
        }

        .dashboard-header h1 {
            color: #333;
            margin-bottom: 10px;
        }

        .dashboard-header p {
            color: #666;
            font-size: 1.1rem;
        }

        .stats-cards {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 40px;
        }

        .stat-card {
            background: white;
            padding: 25px;
            border-radius: 10px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
            text-align: center;
            transition: transform 0.3s ease;
        }

        .stat-card:hover {
            transform: translateY(-5px);
        }

        .stat-icon {
            font-size: 2.5rem;
            margin-bottom: 15px;
        }

        .stat-number {
            font-size: 2rem;
            font-weight: bold;
            margin-bottom: 5px;
        }

        .stat-label {
            color: #666;
            font-size: 0.9rem;
        }

        .stat-books { color: #667eea; }
        .stat-users { color: #28a745; }
        .stat-borrows { color: #ffc107; }
        .stat-overdue { color: #dc3545; }

        .management-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 25px;
            margin-bottom: 40px;
        }

        .management-card {
            background: white;
            border-radius: 10px;
            padding: 25px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }

        .card-header {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 2px solid #f0f0f0;
        }

        .card-icon {
            font-size: 1.5rem;
        }

        .card-title {
            font-size: 1.2rem;
            color: #333;
            font-weight: 600;
        }

        .card-actions {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .action-btn {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 12px 15px;
            background: #f8f9fa;
            border: none;
            border-radius: 6px;
            text-decoration: none;
            color: #333;
            font-size: 0.95rem;
            transition: all 0.3s ease;
            cursor: pointer;
            width: 100%;
            text-align: left;
        }

        .action-btn:hover {
            background: #667eea;
            color: white;
            transform: translateX(5px);
        }

        .recent-activity {
            background: white;
            border-radius: 10px;
            padding: 25px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }

        .activity-list {
            margin-top: 15px;
        }

        .activity-item {
            display: flex;
            align-items: center;
            gap: 15px;
            padding: 12px 0;
            border-bottom: 1px solid #f0f0f0;
        }

        .activity-item:last-child {
            border-bottom: none;
        }

        .activity-icon {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.9rem;
        }

        .activity-borrow { background: #e3f2fd; color: #1976d2; }
        .activity-return { background: #e8f5e8; color: #2e7d32; }
        .activity-add { background: #fff3e0; color: #f57c00; }

        .activity-content {
            flex: 1;
        }

        .activity-title {
            font-weight: 500;
            margin-bottom: 2px;
        }

        .activity-time {
            color: #666;
            font-size: 0.85rem;
        }

        .system-info {
            background: white;
            border-radius: 10px;
            padding: 25px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
            margin-top: 30px;
        }

        .info-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-top: 15px;
        }

        .info-item {
            padding: 15px;
            background: #f8f9fa;
            border-radius: 6px;
        }

        .info-label {
            color: #666;
            font-size: 0.9rem;
            margin-bottom: 5px;
        }

        .info-value {
            font-weight: 600;
            color: #333;
        }
    </style>
</head>
<body>
<!-- 顶部导航 -->
<div class="header">
    <div class="nav-bar">
        <div class="logo">📚 图书管理系统</div>
        <div class="admin-info">
            <span>欢迎，<strong><%= user.getUsername() %></strong></span>
            <span class="admin-badge">管理员</span>
            <a href="../logout" class="logout-btn">退出登录</a>
        </div>
    </div>
</div>

<div class="container">
    <!-- 仪表板头部 -->
    <div class="dashboard-header">
        <h1>管理员控制台</h1>
        <p>系统管理和数据监控中心</p>
    </div>

    <!-- 统计卡片 -->
    <div class="stats-cards">
        <div class="stat-card">
            <div class="stat-icon">📚</div>
            <div class="stat-number stat-books">1,247</div>
            <div class="stat-label">馆藏图书</div>
        </div>
        <div class="stat-card">
            <div class="stat-icon">👥</div>
            <div class="stat-number stat-users">586</div>
            <div class="stat-label">注册用户</div>
        </div>
        <div class="stat-card">
            <div class="stat-icon">📖</div>
            <div class="stat-number stat-borrows">89</div>
            <div class="stat-label">今日借阅</div>
        </div>
        <div class="stat-card">
            <div class="stat-icon">⏰</div>
            <div class="stat-number stat-overdue">12</div>
            <div class="stat-label">逾期未还</div>
        </div>
    </div>

    <!-- 管理功能 -->
    <div class="management-grid">
        <!-- 图书管理 -->
        <div class="management-card">
            <div class="card-header">
                <div class="card-icon">📚</div>
                <div class="card-title">图书管理</div>
            </div>
            <div class="card-actions">
                <a href="book-management.jsp" class="action-btn">
                    <span>📋</span>
                    <span>图书列表管理</span>
                </a>
                <a href="book-add.jsp" class="action-btn">
                    <span>➕</span>
                    <span>添加新图书</span>
                </a>
                <a href="book-import.jsp" class="action-btn">
                    <span>📥</span>
                    <span>批量导入图书</span>
                </a>
                <a href="book-categories.jsp" class="action-btn">
                    <span>🏷️</span>
                    <span>分类管理</span>
                </a>
            </div>
        </div>

        <!-- 用户管理 -->
        <div class="management-card">
            <div class="card-header">
                <div class="card-icon">👥</div>
                <div class="card-title">用户管理</div>
            </div>
            <div class="card-actions">
                <a href="user-management.jsp" class="action-btn">
                    <span>📊</span>
                    <span>用户列表</span>
                </a>
                <a href="user-add.jsp" class="action-btn">
                    <span>👤</span>
                    <span>添加用户</span>
                </a>
                <a href="user-roles.jsp" class="action-btn">
                    <span>🔐</span>
                    <span>权限管理</span>
                </a>
                <a href="user-statistics.jsp" class="action-btn">
                    <span>📈</span>
                    <span>用户统计</span>
                </a>
            </div>
        </div>

        <!-- 借阅管理 -->
        <div class="management-card">
            <div class="card-header">
                <div class="card-icon">📖</div>
                <div class="card-title">借阅管理</div>
            </div>
            <div class="card-actions">
                <a href="borrow-management.jsp" class="action-btn">
                    <span>🔍</span>
                    <span>借阅记录</span>
                </a>
                <a href="borrow-process.jsp" class="action-btn">
                    <span>✅</span>
                    <span>借书/还书处理</span>
                </a>
                <a href="overdue-management.jsp" class="action-btn">
                    <span>⏰</span>
                    <span>逾期管理</span>
                </a>
                <a href="reservation-management.jsp" class="action-btn">
                    <span>📅</span>
                    <span>预约管理</span>
                </a>
            </div>
        </div>
    </div>

    <!-- 最近活动 -->
    <div class="recent-activity">
        <h3>最近活动</h3>
        <div class="activity-list">
            <div class="activity-item">
                <div class="activity-icon activity-borrow">借</div>
                <div class="activity-content">
                    <div class="activity-title">张三 借阅了《Java编程思想》</div>
                    <div class="activity-time">2分钟前</div>
                </div>
            </div>
            <div class="activity-item">
                <div class="activity-icon activity-return">还</div>
                <div class="activity-content">
                    <div class="activity-title">李四 归还了《Spring实战》</div>
                    <div class="activity-time">15分钟前</div>
                </div>
            </div>
            <div class="activity-item">
                <div class="activity-icon activity-add">新</div>
                <div class="activity-content">
                    <div class="activity-title">新增图书《设计模式》</div>
                    <div class="activity-time">1小时前</div>
                </div>
            </div>
            <div class="activity-item">
                <div class="activity-icon activity-borrow">借</div>
                <div class="activity-content">
                    <div class="activity-title">王五 借阅了《数据库系统概念》</div>
                    <div class="activity-time">2小时前</div>
                </div>
            </div>
        </div>
    </div>

    <!-- 系统信息 -->
    <div class="system-info">
        <h3>系统信息</h3>
        <div class="info-grid">
            <div class="info-item">
                <div class="info-label">系统版本</div>
                <div class="info-value">v2.1.0</div>
            </div>
            <div class="info-item">
                <div class="info-label">服务器状态</div>
                <div class="info-value" style="color: #28a745;">正常运行</div>
            </div>
            <div class="info-item">
                <div class="info-label">数据库连接</div>
                <div class="info-value" style="color: #28a745;">正常</div>
            </div>
            <div class="info-item">
                <div class="info-label">最后备份</div>
                <div class="info-value">2025-01-20 03:00</div>
            </div>
        </div>
    </div>
</div>
</body>
</html>